package com.zhisheng.day10_tlias.exception;

import com.zhisheng.day10_tlias.entry.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/*
    统一异常处理器,任意一个controller类中出现异常的时候,这个类都可以处理!!!
 */
@RestControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(Exception.class)
    public R<String> doEx(Exception e){
        e.printStackTrace();
        // 给前端响应一个正常的结果
        return R.fail("亲,别慌,一切尽在掌握中...");
    }


}
